﻿using UnityEngine;
using System.Collections;

public class Popup_TwoButton : Popup_Base
{
    public UILabel m_TitleLabel;
    public UILabel m_BodyLabel;

    public UILabel m_YesButtonLabel_on;
    public UILabel m_YesButtonLabel_off;
    public UILabel m_NoButtonLabel_on;
    public UILabel m_NoButtonLabel_off;

    public override void AwakeInit()
    {       
        m_TitleLabel.text = TextController.GetStringWithId("uiCommonTextYes");
        m_BodyLabel.text = TextController.GetStringWithId("uiCommonTextNo");

        m_PopupSound = "UI_alert_post";
    }

    public void SetPopupWithTitleAndBody(string title, string body)
    {
        m_TitleLabel.text = title;
        m_BodyLabel.text = body;
    }

    public void SetPopupWithYesNoString(string yes, string no)
    {     
        m_YesButtonLabel_on.text = yes;
        m_YesButtonLabel_off.text = yes;
        m_NoButtonLabel_on.text = no;
        m_NoButtonLabel_off.text = no;
    }

    public override void ButtonTouch(Collider collider)
    {
        switch (collider.gameObject.name)
        {
            case "Popup_Button_Yes":
                if (m_MessageRecieaver_OK != null && m_Message_OK != null && m_Message_OK_Parameter != null)
                    m_MessageRecieaver_OK.SendMessage(m_Message_OK, m_Message_OK_Parameter);
				else if (m_MessageRecieaver_OK != null && m_Message_OK != null)
					m_MessageRecieaver_OK.SendMessage(m_Message_OK);
				
                BackButton();
                break;
            case "Popup_Button_No":
				if (m_MessageRecieaver_NO != null && m_Message_NO != null && m_Message_NO_Parameter != null)
					m_MessageRecieaver_NO.SendMessage(m_Message_NO, m_Message_NO_Parameter);
				else if (m_MessageRecieaver_NO != null && m_Message_NO != null)
					m_MessageRecieaver_NO.SendMessage(m_Message_NO);
				
                BackButton();
                break;
            case "Button_Back":
                BackButton();
                break;
        }
    }

    public override void BackButton()
    {        
        PopupManager.PopPopup();
    }
}